////<!-- 告警配置 -->
import api from '../../../fetch/api'

export default {
  data() {
    return {
      emergencyConfig: {
        "blacklistIn": 0,
        "blacklistOut": 0,
        "redlistIn": 0,
        "redlistOut": 0,
        "carnoIn": 0,
        "carnoOut": 0,
        "lmBlacklistIn": 0,
        "lmBlacklistOut": 0,
        "lmRedlistIn": 0,
        "lmRedlistOut": 0,
        "lmCarcodeIn": 0,
        "lmCarcodeOut": 0
      }
    };
  },
  created() {
    this.getConfig();
  },
  methods: {
    getConfig: function() {
      let self = this;
      api.fetchGet('park/emergency/config/get.do', null)
        .then(res => {
          if (res.status == 1) {
            self.emergencyConfig = res.data;
          } else {
            self.showToast(res.message, 2);
          }
        }, err => {});
    },
    updateConfig: function() {
      let self = this;
      api.fetchPost('park/emergency/config/update.do', self.emergencyConfig)
        .then(res => {
          if (res.status != 1) {
            self.showToast(res.message, 2);
            // 出错则重新获取配置
            self.getConfig();
          }
        }, err => { });
    },
    changeStatus: function(){
      this.updateConfig();
    }
  }
}
